#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
class Solution {
public:
    string compressString(string S)
    {
        string s1;
        char start;
        int count = 1;
        for (int i = 0; i < S.size(); i++)
        {
            if (i == 0)
            {
                start = S[i];
                s1 += S[i];
            }
            else
            {

                if (S[i] == start)
                {
                    count++;
                }
                else
                {
                    s1 += to_string(count);
                    s1 += S[i];
                    start = S[i];
                    count = 1;
                }
                
            }

        }
        return s1;
    }
};

//void main()
//{
//    Solution().compressString("aabcccccaa");
//}